package net.es.weathermap.beans;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Domain extends TopologyBean {
    private List<Hub> hubs;

    private Integer timestamp;

    public void setHubs(List<Hub> hubs) {
        this.hubs = hubs;
    }

    public List<Hub> getHubs() {
        return hubs;
    }


    public void setTimestamp(Integer timestamp) {
        this.timestamp = timestamp;
    }

    public Integer getTimestamp() {
        return timestamp;
    }

    public Hub findHub(String hubId) {
        for (Hub hub : hubs) {
            if (hub.getTopoId().equals(hubId)){
                return hub;
            }
        }
        return null;
    }

    public Node findNode(String nodeId) {
        Node res = null;
        for (Hub hub : hubs) {
            for (Node n : hub.getNodes()) {
                if (n.getTopoId().equals(nodeId)) {
                    return n;
                }
            }
        }
        return res;

    }

    public List<String> getAllIfceIds() {
        ArrayList<String> ifceIds = new ArrayList<String>();
        for (Hub hub : hubs) {
            for (Node n : hub.getNodes()) {
                for (String type : new String[] { Connection.IP, Connection.SDN, Connection.PEER } ) {
                    for (IfceConnection c : n.getIfceConnections(type)) {
                        ifceIds.add(c.getTopoId());
                    }
                }
            }
        }
        return ifceIds;
    }


}
